<template>
    <div class="app-container">
    
  
      <el-row :gutter="10" class="mb8">
        <!-- <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['system:role:add']"
              >新增</el-button
            >
          </el-col> -->
        <el-col :span="1.5">
          <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="multiple"
            @click="handleUpdatse"
            v-hasPermi="['system:role:edit']"
            >核对</el-button
          >
        </el-col>
        <!-- <el-col :span="1.5">
          <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
            v-hasPermi="['system:role:remove']">删除</el-button>
        </el-col> -->
        <el-col v-if="user == 'admin'" :span="1.5">
          <!-- <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['system:role:export']"
              >导出</el-button
            > -->
        </el-col>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
      <el-table
        v-loading="loading"
        :data="roleList"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="创建时间" width="150" prop="createTime" />
        <el-table-column label="订单编号" width="150" prop="orderNumber" />
  
        <el-table-column label="原应收（实收）（应退）" width="200" prop="oldMoney"> </el-table-column>
  
        <el-table-column label="新应收（实收）（实退）" width="200" prop="newMoney" />

        <el-table-column label="状态" prop="checkStatus">
          <template slot-scope="scope">
            {{ scope.row.checkStatus == 0 ? "未核对" : '已核对' }}
          </template>
        </el-table-column>
  
        <el-table-column
          fixed="right"
          label="操作"
          align="center"
          width="200"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope" v-if="scope.row.complaintId !== 1">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['system:role:edit']"
              >核对</el-button
            >
            <!-- <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-delete"
                  @click="handleDelete(scope.row)"
                  v-hasPermi="['system:role:remove']"
                  >删除</el-button
                > -->
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :total="total"
        :page.sync="queryParams.pageNo"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </template>
  
  <script>
  import {
    listRole,
    getRole,
    delRole,
    addRole,
    updateRole,
    dataScope,
    changeRoleStatus,
    deptTreeSelect,
  } from "@/api/system/role";
  import { deleteixundan, paizneg } from "@/api/new";
  
  import { listUser, duizhangon,sdsssssss, keudi,wenjuansdsadsd } from "../../api/new";
  import {
    treeselect as menuTreeselect,
    roleMenuTreeselect,
  } from "@/api/system/menu";
  
  export default {

    props:['idsssd'],
    name: "Rolse",
    dicts: ["sys_normal_disable"],
    data() {
      return {
        ketui: "",
        jiaojie: "",
        dai: "",
        // 遮罩层
        loading: true,
        // 选中数组
        xunkong: false,
        ids: [],
        xunkong: false,
        // 非单个禁用
        single: true,
        now: "",
        hounow: 0,
        // 非多个禁用
        kesuwanfrom: {
          recordId: "",
          workDate: "",
          workOne: "",
          workTwo: "",
          restWorker: "",
          remake: null,
        },
        kesuwanfromre: {
          workDate: [
            { required: true, message: "日期不能为空", trigger: "blur" },
          ],
          workOne: [{ required: true, message: "员工不能为空", trigger: "blur" }],
          workTwo: [{ required: true, message: "员工不能为空", trigger: "blur" }],
          restWorker: [
            { required: true, message: "员工不能为空", trigger: "blur" },
          ],
        },
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 角色表格数据
        roleList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        user: this.$store.state.user.name,
        // 是否显示弹出层（数据权限）
        openDataScope: false,
        menuExpand: false,
        menuNodeAll: false,
        deptExpand: true,
        deptNodeAll: false,
        // 日期范围
        dateRange: [],
        // 数据范围选项
  
        yiwei: [
          {
            value: "已成单",
            label: "已成单",
          },
          {
            value: "未成单",
            label: "未成单",
          },
        ],
        // 菜单列表
        menuOptions: [],
        // 部门列表
        deptOptions: [],
        // 查询参数
        queryParams: {
          pageNo: 1,
          pageSize:10,
          dateId:''
        },
        chengdan: [],
        // 表单参数
        form: {},
        defaultProps: {
          children: "children",
          label: "label",
        },
        // 表单校验
        rules: {
          roleName: [
            { required: true, message: "角色名称不能为空", trigger: "blur" },
          ],
          roleKey: [
            { required: true, message: "权限字符不能为空", trigger: "blur" },
          ],
          roleSort: [
            { required: true, message: "角色顺序不能为空", trigger: "blur" },
          ],
        },
      };
    },
    created() {
      this.getList();
    },
  
    methods: {
      xundan() {
        this.$refs["xundanfrom"].validate((valid) => {
          if (valid) {
            if (this.title !== "添加") {
              paizneg([this.kesuwanfrom]).then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.xunkong = false;
                this.getList();
              });
            } else {
              paizneg([this.kesuwanfrom]).then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.xunkong = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 查询角色列表 */
      getList() {
        this.loading = true;

        this.queryParams.dateId=this.idsssd
        sdsssssss(this.queryParams).then((response) => {
          this.roleList = response.rows;
          // this.total = response.total;
          this.loading = false;
        });
      },
  
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 取消按钮（数据权限）
      cancelDataScope() {
        this.openDataScope = false;
        this.reset();
      },
      // 表单重置
      reset() {
        if (this.$refs.menu != undefined) {
          this.$refs.menu.setCheckedKeys([]);
        }
        (this.menuExpand = false),
          (this.menuNodeAll = false),
          (this.deptExpand = true),
          (this.deptNodeAll = false),
          (this.form = {
            complaintId: undefined,
            roleName: undefined,
            roleKey: undefined,
            roleSort: 0,
            status: "0",
            menuIds: [],
            deptIds: [],
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            remark: undefined,
          });
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.startTime = "";
        this.queryParams.endTime = "";
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length != 1;
        this.multiple = !selection.length;
      },
      // 更多操作触发
      handleCommand(command, row) {
        switch (command) {
          case "handleDataScope":
            this.handleDataScope(row);
            break;
          case "handleAuthUser":
            this.handleAuthUser(row);
            break;
          default:
            break;
        }
      },
      // 树权限（展开/折叠）
  
      guanbishoukan() {
        this.kesuwanfrom = {
          recordId: "",
          workDate: this.timestampToDateString(+new Date()),
          workOne: "",
          workTwo: "",
          restWorker: "",
        };
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.kesuwanfrom.workDate = this.timestampToDateString(+new Date());
        this.xunkong = true;
        this.title = "添加";
      },
      /** 修改按钮操作 */
      handleUpdatse() {
       console.log(this.ids);
        wenjuansdsadsd({ids:this.ids.join(',')})   .then((results) => {
            // 所有请求都成功完成，results 是一个包含所有请求结果的数组
            this.$modal.msgSuccess("核对成功");
            this.getList();
          })

      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        wenjuansdsadsd({ids:row.id})   .then((results) => {
            // 所有请求都成功完成，results 是一个包含所有请求结果的数组
            this.$modal.msgSuccess("核对成功");
            this.getList();
          })

      },
  
      /** 提交按钮 */
      submitForm: function () {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            if (this.form.complaintId != undefined) {
              this.form.menuIds = this.getMenuAllCheckedKeys();
              updateRole(this.form).then((response) => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              this.form.menuIds = this.getMenuAllCheckedKeys();
              addRole(this.form).then((response) => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 提交按钮（数据权限） */
      submitDataScope: function () {
        if (this.form.complaintId != undefined) {
          this.form.deptIds = this.getDeptAllCheckedKeys();
          dataScope(this.form).then((response) => {
            this.$modal.msgSuccess("修改成功");
            this.openDataScope = false;
            this.getList();
          });
        }
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const roleIds = row.recordId || this.ids;
        this.$modal
          .confirm("是否确认删除数据项？")
          .then(function () {
            console.log(roleIds);
            return deleteixundan(roleIds);
          })
          .then(() => {
            this.getList();
            this.$modal.msgSuccess("删除成功");
          })
          .catch(() => {});
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download(
          "system/role/export",
          {
            ...this.queryParams,
          },
          `role_${new Date().getTime()}.xlsx`
        );
      },
    },
  };
  </script>
  